package edu.itcs6112.za.repository;

import java.util.List;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;

import edu.itcs6112.za.domain.Item;

public interface ItemRepository extends PagingAndSortingRepository<Item, Long>{

	public final static String FIND_BY_TYPE = "FROM Item i WHERE i.itemType = :itemType";
	public final static String FIND_BY_SEARCH_STRING = "FROM Item i WHERE i.description LIKE :searchString OR i.name LIKE :searchString";
	
	@Query(FIND_BY_TYPE)
	List<Item> findByType(@Param("itemType") String itemType);
	
	@Query(FIND_BY_SEARCH_STRING)
	List<Item> findBySearchString(@Param("searchString") String searchString);
	
}
